package com.wb.core1;

import java.util.Scanner;

/**
 * @author 黄衡熙
 * @version 1.0
 * @date 2025年07月15日13:03
 */
// 在控制台输入指定的年份与月份
// 计算出这一年的这个月共有多少天,考虑闰年
// 采用switch case语句
public class Test8 {
    public static void main(String[] args) {
        while(true) {
            Scanner sc = new Scanner(System.in);
            System.out.print("请输入年份:");
            int year = sc.nextInt();
            System.out.print("请输入月份:");
            int month = sc.nextInt();
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                switch (month) {
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                        System.out.println(year + "年" + month + "月有31天！");
                        break;
                    case 2:
                        System.out.println(year + "年" + month + "月有29天！");
                        break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
                        System.out.println(year + "年" + month + "月有30天！");
                        break;
                    default:
                        System.out.println("不存在" + month + "月");
                }
            } else {
                switch (month) {
                    case 1:
                    case 3:
                    case 5:
                    case 7:
                    case 8:
                    case 10:
                    case 12:
                        System.out.println(year + "年" + month + "月有31天！");
                        break;
                    case 2:
                        System.out.println(year + "年" + month + "月有28天！");
                        break;
                    case 4:
                    case 6:
                    case 9:
                    case 11:
                        System.out.println(year + "年" + month + "月有30天！");
                        break;
                    default:
                        System.out.println("不存在" + month + "月");
                }


            }
        }
    }
}
